package com.set;

import java.util.Arrays;
import java.util.Collection;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

import com.teach.Student1;
import com.teach.Student2;

public class TreeSetTest {
		public static void main(String[] args) {
			TreeSet<Long> ts = new  TreeSet<Long>();
			ts.add(1l);
			ts.add(3l);
			ts.add(2l);
			System.out.println(ts);
			
			Collection<Long> c = Arrays.asList(1l,2l,3l,4l);
			System.out.println(c);
			ts = new TreeSet<Long>(c);
			System.out.println(ts);
			
			
			 ts = new  TreeSet<Long>((a,b)->(int)(b-a));
			ts.add(1l);
			ts.add(3l);
			ts.add(2l);
			System.out.println(ts);
			
			
//			SortedSet<Long> ss = ts;
//			ts = new TreeSet<Long>(ss);
			Set<String> s = new TreeSet<String>();
			s.add("aa");
			s.add("c");
			s.add("b");
			s.add("ad");
			s.add("ab");
			System.out.println(s);
			
			Set<Student1> s1 = new TreeSet<Student1>();
			s1.add(new Student1("张三",3l));
			s1.add(new Student1("李四",1l));
			s1.add(new Student1("王五",2l));
			System.out.println(s1);
			
			//实现了java.lang.Compara ble
		}
		
		
}
